<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:sf="http://www.springframework.org/tags/faces"
	template="/WEB-INF/layouts/standard.xhtml">

	<ui:define name="content">
	
	<ui:fragment id="resultFragment">
		<div class="res">
		<h3>Результаты - #{currtourname}</h3>
		<h:form id="result">
			<ui:fragment id="searchResultsFragment">
				<div id="searchResults"><h:outputText id="noText"
					value="Результаты будут доступны после начала тура"
					rendered="#{currtourid &lt; thistourid}" /> <h:dataTable
					id="dt_result1" value="#{resulth}" var="h"
					rendered="#{isAdmin or currtourid >= thistourid}">
					<h:column>
						<h:dataTable id="dt_result2" styleClass="summary"
							value="#{result}" var="s"
							rowClasses="list-row-even,list-row-odd"
							columnClasses="colPlace,colUser,colTotal,colCenter,colCenter,colCenter,colCenter,colCenter,colCenter,colCenter,colCenter">
							<h:column>
								<f:facet name="header">
									<sf:commandLink id="sortByPlaceLink" action="sort"
										value="Место #{h.placeTour}" processIds="*">
										<f:param name="sortBy" value="placeTour" />
									</sf:commandLink>
								</f:facet>
								<h:outputText value="#{s.placeTour}"
									style="font-weight:bold;color:#{s.placeTour== 1 ? 'darkred' : 'black'}" />
							</h:column>
							<h:column>
								<c:if test="${not empty currentUser.name}">
									<f:facet name="header">
										<sf:commandLink id="sortByUsernameLink" action="sort"
											value="Участник" processIds="*">
											<f:param name="sortBy" value="fullname" />
										</sf:commandLink>
									</f:facet>
									<h:outputText value="#{s.fullname}" style="font-weight:bold;color:#{s.placeTour== 1 ? 'darkred' : 'black'}" />
								</c:if>
								<c:if test="${empty currentUser.name}">
									<f:facet name="header">
										<sf:commandLink id="sortByUsernameLink" action="sort"
											value="Участник" processIds="*">
											<f:param name="sortBy" value="username" />
										</sf:commandLink>
									</f:facet>
									<h:outputText value="#{s.username}" style="font-weight:bold;color:#{s.placeTour== 1 ? 'darkred' : 'black'}" />
								</c:if>
							</h:column>
							<h:column>
								<f:facet name="header">
									<sf:commandLink id="sortByPointsLink" action="sort"
										value="Всего очков #{h.pointsTour}" processIds="*">
										<f:param name="sortBy" value="placeTour" />
									</sf:commandLink>
								</f:facet>
								<h:outputText value="#{s.pointsTour} "
									style="color:#{s.placeTour== 1 ? 'darkred' : 'black'}" />
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText escape="false" value="#{h.m1}">
										<sf:commandLink id="editMatch1" action="editmatch" processIds="*" rendered="#{isAdmin}">
											<f:param name="matchid" value="#{h.mid1}" />
											<h:graphicImage url="/resources/images/EditIcon.gif"/>
										</sf:commandLink>
										<br/>
									</h:outputText>
								</f:facet>
								<ui:fragment rendered="#{isAdmin and s.sorting == 2}">
									<sf:commandLink id="editScore1" action="editscore" processIds="*">
										<f:param name="matchid" value="#{h.mid1}" />
										<h:graphicImage url="/resources/images/EditIcon.gif"/>
									</sf:commandLink>
									<br/>
								</ui:fragment>
								<h:outputText value="#{s.m1}"
									style="color:#{s.placeTour == 1 ? 'darkred' : 'black'}" />
							</h:column>
							<h:column>
								<f:facet name="header">
									<h:outputText escape="false" value="#{h.m2}" >
										<sf:commandLink id="editMatch2" action="editmatch" processIds="*" rendered="#{isAdmin}">
											<f:param name="matchid" value="#{h.mid2}" />
											<h:graphicImage url="/resources/images/EditIcon.gif"/>
										</sf:commandLink>
										<br/>
									</h:outputText>
								</f:facet>
								<ui:fragment rendered="#{isAdmin and s.sorting == 2}">
									<sf:commandLink id="editScore2" action="editscore" processIds="*">
										<f:param name="matchid" value="#{h.mid2}" />
										<h:graphicImage url="/resources/images/EditIcon.gif"/>
									</sf:commandLink>
									<br/>
								</ui:fragment>
								<h:outputText value="#{s.m2}"
									style="color:#{s.placeTour == 1 ? 'darkred' : 'black'}" />
							</h:column>
						</h:dataTable>
					</h:column>
				</h:dataTable></div>
			</ui:fragment>
		</h:form></div>
	</ui:fragment>
	
	</ui:define>
</ui:composition>